package com.tech.cloudapp.db.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 题目信息表
 * </p>
 *
 * @author mojianyou
 * @since 2025-03-23
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class QuestionInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 自增主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 所属试卷ID
     */
    private Integer paperId;

    /**
     * 题目排序序号
     */
    @TableField("`order`")
    private Integer order;

    /**
     * 题目类型（如单选/多选）
     */
    private String questionType;

    /**
     * 题目内容
     */
    private String title;

    /**
     * 选项字母标识
     */
    private String answerLetter;

    /**
     * 正确答案字母
     */
    private String rightAnswerLetter;

    /**
     * 选项文本内容
     */
    private String answerText;

    /**
     * 题目解析
     */
    private String answerSolution;

    /**
     * 分类ID
     */
    private Integer classifyId;


    public List<String> getAnswerText() {

        if (StringUtils.isEmpty(this.answerText)) return new ArrayList<>();
        List list = JSON.parseArray(this.answerText);
        return list;
    }


    public List<String> getAnswerLetter()
    {
        if (StringUtils.isEmpty(this.answerLetter)) return new ArrayList<>();
        List list = JSON.parseArray(this.answerLetter);
        return list;
    }

    public List<String> getRightAnswerLetter()
    {
        if (StringUtils.isEmpty(this.rightAnswerLetter)) return new ArrayList<>();
        List list = JSON.parseArray(this.rightAnswerLetter);
        return list;
    }
}
